package cn.swh.guguanjia.mapper;

import com.alibaba.excel.util.StringUtils;
import org.apache.ibatis.jdbc.SQL;

import java.util.Map;

/**
 * @Author: swh
 * @Description:
 * @Date: 2020/11/3 18:26
 * @Version: 1.0
 */
public class SysUserProvider {
    public String selectPage(Map<String, Object> map) {
        return new SQL() {{
            SELECT(" su.*, " +
                    " sr.`name` role_name, " +
                    " so.`name` office_name ");
            FROM(" sys_user su, " +
                    " sys_user_role sur, " +
                    " sys_role sr, " +
                    " sys_office so");
            WHERE("su.del_flag =0");
            WHERE("su.id=sur.user_id");
            WHERE("sr.id=sur.role_id");
            WHERE("su.office_id=so.id");
            if (map.containsKey("name") && !StringUtils.isEmpty(map.get("name"))) {
                WHERE(" su.name like CONCAT('%',#{name},'%')");
            }
        }}.toString();
    }
}
